package com.shaozi.nc.data.mongodao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Repository;

import com.shaozi.data.mongo.dao.SZMongoBaseDao;
import com.shaozi.lib.throwable.SzException;
import com.shaozi.nc.data.model.SecretaryApiQuartzLogModel;

@Repository("secretaryApiQuartzLogMDao")
public class SecretaryApiQuartzLogMDao extends SZMongoBaseDao<SecretaryApiQuartzLogModel> {

	@Autowired
	public SecretaryApiQuartzLogMDao(MongoTemplate shaoziTemplate) {
		super(shaoziTemplate);
	}

	public void save(String companyId, SecretaryApiQuartzLogModel model) throws SzException {
		if (model.getCreateTime() == null) {
			model.setCreateTime(System.currentTimeMillis());
		}
		model.setCompanyId(companyId);
		String shardingId = this.getShardingIdByYYYYMM("");
		getMongoTemplate().save(model, getCollectionName(shardingId));
	}

}
